﻿Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports NUnit.Framework
Imports System.Diagnostics

Namespace Axial.Tests
    <TestFixture()> _
    Public Class WhileTests
        Inherits TestBase
        <Test()> _
        Public Sub SimpleTest()
            Dim check As String = "while (a > b)" & vbNewLine & vbTab & "a = 3;"
            check = VerifyMethodOutput("Simple", check)
        End Sub
        Public Sub Simple()
            Dim a As Integer = 2, b As Integer = 1
            While a > b
                a = 3
            End While
        End Sub

        <Test()> _
        Public Sub ConditionsTest()
            Dim check As String = "while (a == b)" & vbNewLine & vbTab & "a = 3;" & vbNewLine & "while (a != b)" & vbNewLine & vbTab & "a = 3;" & vbNewLine & "while (a > b)" & vbNewLine & vbTab & "a = 3;" & vbNewLine & "while (a >= b)" & vbNewLine & vbTab & "a = 3;" & vbNewLine & "while (a <= b)" & vbNewLine & vbTab & "a = 3;" & vbNewLine & "while (a < b)" & vbNewLine & vbTab & "a = 3;"
            check = VerifyMethodOutput("Conditions", check)
        End Sub
        Public Sub Conditions()
            Dim a As Integer = 2, b As Integer = 1
            While a = b
                a = 3
            End While
            While a <> b
                a = 3
            End While
            While a > b
                a = 3
            End While
            While a >= b
                a = 3
            End While
            While a <= b
                a = 3
            End While
            While a < b
                a = 3
            End While
        End Sub

        <Test()> _
        Public Sub OrTest()
            Dim check As String = "while (a == b || c == 4)" & vbNewLine & vbTab & "a = 15;"
            check = VerifyMethodOutput("Or", check)
        End Sub
        Public Sub [Or]()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b OrElse c = 4
                a = 15
            End While
        End Sub

        <Test()> _
        Public Sub OrAndTest()
            Dim check As String = "while (a == b || c == 4 && a == c)" & vbNewLine & vbTab & "a = 15;"
            check = VerifyMethodOutput("OrAnd", check)
        End Sub
        Public Sub OrAnd()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b OrElse c = 4 AndAlso a = c
                a = 15
            End While
        End Sub

        <Test()> _
        Public Sub AndTest()
            Dim check As String = "while (a == b && c == 4)" & vbNewLine & vbTab & "a = 15;"
            check = VerifyMethodOutput("And", check)
        End Sub
        Public Sub [And]()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b AndAlso c = 4
                a = 15
            End While
        End Sub

        <Test()> _
        Public Sub AndOrTest()
            Dim check As String = "while (a == b && c == 4 || a > c)" & vbNewLine & vbTab & "a = 15;"
            check = VerifyMethodOutput("AndOr", check)
        End Sub
        Public Sub AndOr()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b AndAlso c = 4 OrElse a > c
                a = 15
            End While
        End Sub

        <Test()> _
        Public Sub AndOrWhileTest()
            Dim check As String = "while (a == b && c == 4 || a < c)" & vbNewLine & vbTab & "while (b == 2)" & vbNewLine & vbTab & vbTab & "a = 15;"
            check = VerifyMethodOutput("AndOrWhile", check)
        End Sub
        Public Sub AndOrWhile()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b AndAlso c = 4 OrElse a < c
                While b = 2
                    a = 15
                End While
            End While
        End Sub

        <Test()> _
        Public Sub AndOrWhileStatementTest()
            Dim check As String = _
"while (a == b && c == 4 || a == c)" & vbNewLine & _
"{" & vbNewLine & _
vbTab & "while (b == 2)" & vbNewLine & _
vbTab & vbTab & "a = 15;" & vbNewLine & _
vbTab & "c = 10;" & vbNewLine & _
"}"
            check = VerifyMethodOutput("AndOrWhileStatement", check)
        End Sub
        Public Sub AndOrWhileStatement()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b AndAlso c = 4 OrElse a = c
                While b = 2
                    a = 15
                End While
                c = 10
            End While
        End Sub

        <Test()> _
        Public Sub OrAndWhileTest()
            Dim check As String = "while (a == b || c == 4 && a == c)" & vbNewLine & vbTab & "while (b == 2)" & vbNewLine & vbTab & vbTab & "a = 15;"
            check = VerifyMethodOutput("OrAndWhile", check)
        End Sub
        Public Sub OrAndWhile()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b OrElse c = 4 AndAlso a = c
                While b = 2
                    a = 15
                End While
            End While
        End Sub

        <Test()> _
        Public Sub And3Test()
            Dim check As String = "while (a == b && c == 4 && a == 2)" & vbNewLine & vbTab & "a = 15;"
            check = VerifyMethodOutput("And3", check)
        End Sub
        Public Sub And3()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b AndAlso c = 4 AndAlso a = 2
                a = 15
            End While
        End Sub

        <Test()> _
        Public Sub Or3Test()
            Dim check As String = "while (a == b || c == 4 || a == 2)" & vbNewLine & vbTab & "a = 15;"
            check = VerifyMethodOutput("Or3", check)
        End Sub
        Public Sub Or3()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b OrElse c = 4 OrElse a = 2
                a = 15
            End While
        End Sub

        <Test()> _
        Public Sub VeryLongTest()
            Dim check As String = "while (a == b && c != 4 && a > 2 && b < 3 && a >= c && c <= b && a == 3)" & vbNewLine & vbTab & "a = 10;"
            check = VerifyMethodOutput("VeryLong", check)
        End Sub
        Public Sub VeryLong()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b AndAlso c <> 4 AndAlso a > 2 AndAlso b < 3 AndAlso a >= c AndAlso c <= b AndAlso a = 3
                a = 10
            End While
        End Sub

        <Test()> _
        Public Sub VeryLongMixedTest()
            Dim check As String = "while (a == b || c != 4 || a > 2 && b < 3 || a >= c && c <= b || a == 3)" & vbNewLine & vbTab & "a = 10;"
            check = VerifyMethodOutput("VeryLongMixed", check)
        End Sub
        Public Sub VeryLongMixed()
            Dim a As Integer = 2, b As Integer = 1, c As Integer = 3
            While a = b OrElse c <> 4 OrElse a > 2 AndAlso b < 3 OrElse a >= c AndAlso c <= b OrElse a = 3
                a = 10
            End While
        End Sub

        <Test()> _
        Public Sub WhileWhileTest()
            VerifyMethodOutput("WhileWhile", "while (a == 1)" & vbNewLine & vbTab & "a = 2;" & vbNewLine & "while (b == 2)" & vbNewLine & vbTab & "b = 1;")
        End Sub
        Public Sub WhileWhile()
            Dim a As Integer = 0
            Dim b As Integer = 1
            While a = 1
                a = 2
            End While
            While b = 2
                b = 1
            End While
        End Sub
    End Class
End Namespace